<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>

    </style>
</head>

<body>
    <div id="app">
        <h3>计算属性</h3>
        <h3>
            {{ count }}
        </h3>
        <button @click="count += 1">++</button>
        <div>
            {{ newCount }}
        </div>
        <div>
            {{ newCount }}
        </div>
        <div>
            {{ newCount }}
        </div>
        <div>
            {{ newCount }}
        </div>
        <div>
            {{ newCount }}
        </div>
    </div>

    <script src="./js/vue.js"></script>
    <script>
        const app = new Vue({
            el: "#app",
            data: {
                count: 200
            },
            methods: {

            },
            // 计算属性
            // 1. 缓存
            // 2. 只要依赖的值不发生改变，就不会重新再进行计算
            computed: {
                newCount({ count }) {
                    console.log(111)
                    return count.toFixed(2)
                }
            }
        })
        
    </script>
</body>

</html>